/*********************************
*-- 33 KDH Knieja ---------------*
*-- im. Harcerzy Września 1939 --*
*-- autor: Marcin Rzepisko ------*
*-- data: 2013-11-16 ------------*
**********************************/

package net.kdh.knieja.dao.polaczenie;

/**
 *
 * @author rz.marcin@gmail.com
 */
public class ParametryPolaczenia {
    private final String ADRES = "192.168.0.123";
    private final String PORT = "3306";
    private final String DRIVER = "com.mysql.jdbc.Driver";
    private final String PREFIX = "KNIEJA_";
    private String connectionString;
    private DaneDostepuEnum daneDostepu;  

    public String getADRES() {
        return ADRES;
    }

    public String getPORT() {
        return PORT;
    }

    public String getDRIVER() {
        return DRIVER;
    }

    public String getPREFIX() {
        return PREFIX;
    }

    public DaneDostepuEnum getDaneDostepu() {
        return daneDostepu;
    }

    public void setDaneDostepu(DaneDostepuEnum daneDostepu) {
        this.daneDostepu = daneDostepu;
    }

    
    public String getConnectionString() {
        if(connectionString == null || "".equals(connectionString)) {
            generujConnectionString();
        }
        return connectionString;
    }
    
    //jdbc:mysql://192.168.56.101:3306/KNIEJA_"
    private void generujConnectionString() {
        StringBuilder sB = new StringBuilder();
        sB.append("jdbc:mysql://")
            .append(getADRES())
            .append(":")
            .append(getPORT())
            .append("/")
            .append(getPREFIX())
            .append(daneDostepu.getDB_SCHEMA());
        connectionString = sB.toString();
    }
}
